package shajie.shajun.mmhf.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import shajie.shajun.mmhf.Control.NumAnim2;
import shajie.shajun.mmhf.R;

/**
 * Created by admin on 2017/11/23.
 */

public class GridAdapter extends BaseAdapter {
    public LayoutInflater inflater;
    public List<String> shopmoney;

    public GridAdapter(Context context, List<String> shopmoney) {
        inflater = LayoutInflater.from(context);
        this.shopmoney = shopmoney;
    }
    @Override
    public int getCount() {
        return shopmoney.size();
    }

    @Override
    public String getItem(int position) {
        return shopmoney.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        String currStr = getItem(position);
        String[] strings;
        strings=currStr.split(":");
        View view;
        ViewHolder holder;
        if(convertView == null)
        {
            view = inflater.inflate(R.layout.item_shopmoney, null);
            holder = new ViewHolder();

            holder.money = (TextView) view.findViewById(R.id.tv_money);
            holder.title = (TextView) view.findViewById(R.id.tv_moneytitle);

            view.setTag(holder);
        }else
        {
            view = convertView;
            holder = (ViewHolder) view.getTag();
        }
        float money=Float.valueOf(strings[1]);
        if (position==1) {
           // if (Public_Data.p_user.getUsername().equals("s476606729")) {
                NumAnim2.startAnim(holder.money, money);
//            }else {
//                holder.money.setText("******");
//            }
        }else {
            NumAnim2.startAnim(holder.money, money);
            //  holder.money.setText(strings[1]);
        }
        holder.title.setText(strings[0]);
        return view;
    }


    static class ViewHolder
    {
        TextView money,title;
    }
}